using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using MLC = MicroLiquidCrystal;

namespace Netduino4Fun.Framework.ElectronicBrick
{
    public class Lcd
    {
        public MLC.Lcd display;

        public Lcd()
        {
            MLC.GpioLcdTransferProvider lcdProvider = new MLC.GpioLcdTransferProvider(
                                                            Bus.Bus2.Pins[0],
                                                            Bus.Bus2.Pins[1],
                                                            Bus.Bus2.Pins[2],
                                                            Bus.Bus2.Pins[3],
                                                            Bus.Bus2.Pins[4],
                                                            Bus.Bus2.Pins[5],
                                                            Bus.Bus2.Pins[6]
                                                        );

            MLC.Lcd lcd = new MLC.Lcd(lcdProvider);
            lcd.Begin(16, 2);
            lcd.Clear();

            this.display = lcd;
        }

        public void Write(string text)
        {
            this.display.Write(text);
        }

        public void Clear()
        {
            this.display.Clear();
        }

        public bool BlinkCursor
        {
            get { return this.display.BlinkCursor; }
            set { this.display.BlinkCursor = value; }
        }

        public bool ShowCursor
        {
            get { return this.display.ShowCursor; }
            set { this.display.ShowCursor = value; }
        }

        public void MoveCursorLeft()
        {
            this.display.MoveCursor(false);
        }

        public void MoveCursorRight()
        {
            this.display.MoveCursor(true);
        }
    }
}
